package com.chixing.day04;

/**
 * 方法中的参数传递:
 * (1)值传递：基本数据类型的值 被复制一份,有两个独立的值
 * int a = 10;
 * int b = a;
 * (2)地址传递:引用数据类型的赋值 指向同一块堆内存
 * Car car1 = new Car(102,"ccc","TELSA")
 * Car car2 = car1
 */
public class MethodDemo {
    //值传递：基本数据类型的值 被复制一份,有两个独立的值
    public static void fun1(int x) {
        x = 20;
    }

    //地址传递:引用数据类型的赋值 指向同一块堆内存
    public static void fun2(Car car) {
        car.setCarName("zzz");
        car.setCarColor("奔驰");
    }

    public static void fun3(int[] a) {
        a[0] = 99;
    }

    public static void main(String[] args) {
        int x = 10;
        fun1(x);
        System.out.println("x = " + x); //10
        Car car = new Car(101, "DDD", "特斯拉");
        fun2(car);
        System.out.println("car name: " + car.getCarName());
        System.out.println("car coloe: " + car.getCarColor());

        int[] a = {10, 20, 30};
        fun3(a);
        System.out.println("a[0]: " + a[0]);


      /*  public MethodDemo fun1(){
            return  null;
        }
        public MethodDemo fun2(){
            return   new Account();
        }

        public MethodDemo fun3(){
            return    this;
        }

        public int fun4(){
            return  0;
        }
*/
    }
}
